home *** CD-ROM | disk | FTP | other *** search
/ Total Network Tools 2002 / NextStepPublishing-TotalNetworkTools2002-Win95.iso / Archive / Misc Servers / Zope.exe / DTML-IN.STX < prev    next >
Encoding:
Text File  |  2000-10-12  |  7.0 KB  |  230 lines

  1. in: Loops over sequences
  2.  
  3.   The 'in' tag gives you powerful controls for looping over sequences
  4.   and performing batch processing.
  5.  
  6.   Syntax
  7.  
  8.     'in' tag syntax::
  9.  
  10.       <dtml-in SequenceVariable|expr="SequenceExpression">
  11.       [<dtml-else>]
  12.       </dtml-in>
  13.  
  14.     The 'in' block is repeated once for each item in the sequence
  15.     variable or sequence expression. The current item is pushed on to
  16.     the DTML namespace during each executing of the 'in' block.
  17.  
  18.     If there are no items in the sequence variable or expression, the
  19.     optional 'else' block is executed.
  20.  
  21.   Attributes
  22.  
  23.     mapping -- Iterates over mapping objects rather than
  24.     instances. This allows values of the mapping objects to be
  25.     accessed as DTML variables.
  26.  
  27.     reverse -- Reverses the sequence.
  28.  
  29.     sort=string -- Sorts the sequence by the given attribute name.
  30.  
  31.     start=int -- Begins the batch with the given index number.
  32.  
  33.     size=int -- The size of the batch.
  34.  
  35.     skip_unauthorized -- Don't raise an exception if an unauthorized
  36.     item is encountered.
  37.  
  38.     orphan=int -- The desired minimum batch size.
  39.  
  40.     overlap=int -- The number of items to overlap between batches.
  41.  
  42.     previous -- Iterates once if there is a previous batch. Sets batch
  43.     variables for previous sequence. 
  44.  
  45.     next -- Iterates once if there is a next batch. Sets batch variables
  46.     for the next sequence.
  47.  
  48.   Tag Variables
  49.  
  50.     Current Item Variables
  51.  
  52.       These variables describe the current item.
  53.  
  54.         sequence-item -- The current item.
  55.  
  56.         sequence-key -- The current key. When looping over tuples of the
  57.         form '(key,value)', the 'in' tag interprets them as
  58.         '(sequence-key, sequence-item)'. 
  59.  
  60.         sequence-index -- The index starting with 0 of the current item.
  61.  
  62.         sequence-number -- The index starting with 1 of the current item.
  63.  
  64.         sequence-roman -- The index in lowercase Roman numerals of the
  65.         current item.
  66.  
  67.         sequence-Roman -- The index in uppercase Roman numerals of the
  68.         current item.
  69.  
  70.         sequence-letter -- The index in lowercase letters of the current
  71.         item.
  72.  
  73.         sequence-Letter -- The index in uppercase letters of the current
  74.         item.
  75.  
  76.         sequence-start -- True if the current item is the first item.
  77.  
  78.         sequence-end -- True if the current item is the last item.
  79.  
  80.         sequence-even -- True if the index of the current item is even.
  81.  
  82.         sequence-odd -- True if the index of the current item is odd.
  83.  
  84.         sequence-length -- The length of the sequence.
  85.  
  86.         sequence-var-*variable* -- A variable in the current item. For
  87.         example, 'sequence-var-title' is the 'title' variable of the
  88.         current item. Normally you can access these variables directly
  89.         since the current item is pushed on the DTML namespace. However
  90.         these variables can be useful when displaying previous and next
  91.         batch information.
  92.  
  93.         sequence-index-*variable* -- The index of a variable of the
  94.         current item.
  95.  
  96.     Summary Variables
  97.  
  98.       These variable summarize information about numeric item
  99.       variables. To use these variable you must loop over objects
  100.       (like database query results) that have numeric variables.
  101.  
  102.         total-*variable* -- The total of all occurrences of an item variable. 
  103.  
  104.         count-*variable* -- The number of occurrences of an item variable.
  105.  
  106.         min-*variable* -- The minimum value of an item variable.
  107.  
  108.         max-*variable* -- The maximum value of an item variable.
  109.  
  110.         mean-*variable* -- The mean value of an item variable.
  111.  
  112.         variance-*variable* -- The variance of an item variable with
  113.         count-1 degrees of freedom. 
  114.  
  115.         variance-n-*variable* -- The variance of an item variable with
  116.         count degrees of freedom. 
  117.  
  118.         standard-deviation-*variable* -- The standard-deviation of an
  119.         item variable with count-1 degrees of freedom.
  120.  
  121.         standard-deviation-n-*variable* -- The standard-deviation of
  122.         an item variable with count degrees of freedom.
  123.  
  124.     Grouping Variables
  125.  
  126.       These variables allow you to track changes in current item
  127.       variables.
  128.  
  129.         first-*variable* -- True if the current item is the first with
  130.         a particular value for a variable.
  131.  
  132.         last-*variable* -- True if the current item is the last with a
  133.         particular value for a variable.
  134.  
  135.     Batch Variables
  136.  
  137.       sequence-query -- The query string with the 'start' variable
  138.       removed. You can use this variable to construct links to next
  139.       and previous batches.
  140.  
  141.       sequence-step-size -- The batch size.
  142.  
  143.       previous-sequence -- True if the current batch is not the
  144.       first one. Note, this variable is only true the first loop
  145.       iteration. 
  146.  
  147.       previous-sequence-start-index -- The starting index of the
  148.       previous batch.
  149.  
  150.       previous-sequence-end-index -- The ending index of the previous
  151.       batch. 
  152.  
  153.       previous-sequence-size -- The size of the previous batch.
  154.  
  155.       previous-batches -- A sequence of mapping objects with
  156.       information about all previous batches. Each mapping object has
  157.       these keys 'batch-start-index', 'batch-end-index', and
  158.       'batch-size'.
  159.  
  160.       next-sequence -- True if the current batch is not the last
  161.       batch. Note, this variable is only true for the last loop
  162.       iteration. 
  163.  
  164.       next-sequence-start-index -- The starting index of the next
  165.       sequence. 
  166.  
  167.       next-sequence-end-index -- The ending index of the next
  168.       sequence. 
  169.  
  170.       next-sequence-size -- The size of the next index.
  171.  
  172.       next-batches -- A sequence of mapping objects with information
  173.       about all following batches. Each mapping object has these keys
  174.       'batch-start-index', 'batch-end-index', and 'batch-size'.
  175.  
  176.   Examples
  177.  
  178.     Looping over sub-objects::
  179.  
  180.       <dtml-in objectValues>
  181.         title: <dtml-var title><br>
  182.       </dtml-in>
  183.  
  184.     Looping over a list of '(key, value)' tuples::
  185.  
  186.       <dtml-in objectItems>
  187.         id: <dtml-var sequence-key>, title: <dtml-var title><br>
  188.       </dtml-in> 
  189.  
  190.     Creating alternate colored table cells::
  191.  
  192.       <table>
  193.       <dtml-in objectValues>
  194.       <tr <dtml-if sequence-odd>bgcolor="#EEEEEE"
  195.           <dtml-else>bgcolor="#FFFFFF"
  196.           </dtml-if>
  197.         <td><dtml-var title></td>
  198.       </tr>
  199.       </dtml-in>
  200.       </table>
  201.  
  202.     Basic batch processing::
  203.  
  204.       <p>
  205.       <dtml-in largeSequence size=10 start=start previous>
  206.         <a href="<dtml-var absolute_url>?start=<dtml-var previous-sequence-start-index>">Previous</a>
  207.       </dtml-in>
  208.  
  209.       <dtml-in largeSequence size=10 start=start next>
  210.         <a href="<dtml-var absolute_url>?start=<dtml-var next-sequence-start-index>">Next</a>
  211.       </dtml-in>
  212.       </p>
  213.  
  214.       <p>
  215.       <dtml-in largeSequence size=10 start=start>
  216.         <dtml-var sequence-item>
  217.       </dtml-in>
  218.       </p>
  219.  
  220.     This example creates *Previous* and *Next* links to navigate
  221.     between batches.
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.